<?php
/**
 * Created by jinqiang on 2024/7/11 13:25.
 * Copyright (c) 2024, Your Company. All rights reserved.
 */


namespace App\Http\Controllers\Produce;


use App\Http\Controllers\Controller;
use App\Http\Services\Produce\LiningService;
use Illuminate\Http\Request;

class LiningController extends Controller
{
    public function list(Request $request, LiningService $liningService)
    {
        $this->validate($request, [
            'page' => 'required',
            'limit' => 'required'
        ]);
        $param = $request->all();
        $res = $liningService->search($param);
        return result($res);
    }

    public function checkList(Request $request, LiningService $liningService)
    {
        $this->validate($request, [
            'page' => 'required',
            'limit' => 'required'
        ]);
        $param = $request->all();
        $res = $liningService->searchCheck($param);
        return result($res);
    }

    public function del(Request $request, LiningService $liningService)
    {
        $this->validate($request, [
            'id' => 'required'
        ]);
        $param = $request->all();
        $res = $liningService->del($param['id']);
        return $res['code'] === 0 ? success("删除成功") : error($res['msg'], $res);
    }

    public function suixiBase()
    {
        $data = [
            [
                'ximaiid' => 1,
                'ximainame' => "涤纶、锦纶、棉、人棉、天丝、羊毛低比例混纺类服装",
                'ximaiimg' => [
                    'https://ssy.13yu.com/Public/shuiximai/shouxi.png',
                    'http://ssy.13yu.com/Public/shuiximai/bukepiaobai.png',
                    'https://ssy.13yu.com/Public/shuiximai/xuangualianggan.png',
                    'https://ssy.13yu.com/Public/shuiximai/diwenyuntang.png',
                    'https://ssy.13yu.com/Public/shuiximai/bukeganxi.png'
                ]
            ],[
                'ximaiid' => 2,
                'ximainame' => "醋酸类服装",
                'ximaiimg' => [
                    'https://ssy.13yu.com/Public/shuiximai/shouxi.png',
                    'http://ssy.13yu.com/Public/shuiximai/bukepiaobai.png',
                    'https://ssy.13yu.com/Public/shuiximai/zhengchangwendujigan.png',
                    'https://ssy.13yu.com/Public/shuiximai/diwenyuntang.png',
                    'https://ssy.13yu.com/Public/shuiximai/changuiganxi.png'
                ]
            ],[
                'ximaiid' => 3,
                'ximainame' => "丝绸服装",
                'ximaiimg' => [
                    'https://ssy.13yu.com/Public/shuiximai/shouxi.png',
                    'http://ssy.13yu.com/Public/shuiximai/bukepiaobai.png',
                    'http://cdn.13yu.com/shuiximai/yinliangchulianggan.png',
                    'https://ssy.13yu.com/Public/shuiximai/diwenyuntang.png',
                    'https://ssy.13yu.com/Public/shuiximai/bukeganxi.png'
                ]
            ],[
                'ximaiid' => 4,
                'ximainame' => "毛呢类服装",
                'ximaiimg' => [
                    'https://ssy.13yu.com/Public/shuiximai/bukeshuixi.png',
                    'http://ssy.13yu.com/Public/shuiximai/bukepiaobai.png',
                    'https://ssy.13yu.com/Public/shuiximai/zhengchangwendujigan.png',
                    'https://ssy.13yu.com/Public/shuiximai/zhongwenyuntang.png',
                    'https://ssy.13yu.com/Public/shuiximai/changuiganxi.png'
                ]
            ],[
                'ximaiid' => 5,
                'ximainame' => "化纤毛呢服装",
                'ximaiimg' => [
                    'https://ssy.13yu.com/Public/shuiximai/changguixidi.png',
                    'http://ssy.13yu.com/Public/shuiximai/bukepiaobai.png',
                    'https://ssy.13yu.com/Public/shuiximai/xuangualianggan.png',
                    'https://ssy.13yu.com/Public/shuiximai/zhongwenyuntang.png',
                    'https://ssy.13yu.com/Public/shuiximai/bukeganxi.png'
                ]
            ],[
                'ximaiid' => 6,
                'ximainame' => "人造毛皮服装",
                'ximaiimg' => [
                    'https://ssy.13yu.com/Public/shuiximai/changguixidi.png',
                    'http://ssy.13yu.com/Public/shuiximai/bukepiaobai.png',
                    'https://ssy.13yu.com/Public/shuiximai/xuangualianggan.png',
                    'https://ssy.13yu.com/Public/shuiximai/bukeyuntang.png',
                    'https://ssy.13yu.com/Public/shuiximai/bukeganxi.png'
                ]
            ],[
                'ximaiid' => 7,
                'ximainame' => "针织类服装",
                'ximaiimg' => [
                    'https://ssy.13yu.com/Public/shuiximai/changguixidi.png',
                    'http://ssy.13yu.com/Public/shuiximai/bukepiaobai.png',
                    'https://ssy.13yu.com/Public/shuiximai/xuangualianggan.png',
                    'https://ssy.13yu.com/Public/shuiximai/zhongwenyuntang.png',
                    'https://ssy.13yu.com/Public/shuiximai/bukeganxi.png'
                ]
            ],[
                'ximaiid' => 8,
                'ximainame' => "羽绒服",
                'ximaiimg' => [
                    'https://ssy.13yu.com/Public/shuiximai/huanhexidi.png',
                    'http://ssy.13yu.com/Public/shuiximai/bukepiaobai.png',
                    'https://ssy.13yu.com/Public/shuiximai/xuangualianggan.png',
                    'https://ssy.13yu.com/Public/shuiximai/bukeyuntang.png',
                    'https://ssy.13yu.com/Public/shuiximai/bukeganxi.png'
                ]
            ],[
                'ximaiid' => 9,
                'ximainame' => "棉服",
                'ximaiimg' => [
                    'https://ssy.13yu.com/Public/shuiximai/changguixidi.png',
                    'http://ssy.13yu.com/Public/shuiximai/bukepiaobai.png',
                    'https://ssy.13yu.com/Public/shuiximai/diwenjigan.png',
                    'https://ssy.13yu.com/Public/shuiximai/diwenyuntang.png',
                    'https://ssy.13yu.com/Public/shuiximai/bukeganxi.png'
                ]
            ],[
                'ximaiid' => 10,
                'ximainame' => "牛仔服装",
                'ximaiimg' => [
                    'https://ssy.13yu.com/Public/shuiximai/changguixidi.png',
                    'http://ssy.13yu.com/Public/shuiximai/bukepiaobai.png',
                    'https://ssy.13yu.com/Public/shuiximai/xuangualianggan.png',
                    'https://ssy.13yu.com/Public/shuiximai/zhongwenyuntang.png',
                    'https://ssy.13yu.com/Public/shuiximai/bukeganxi.png'
                ]
            ],[
                'ximaiid' => 12,
                'ximainame' => "双面呢服装",
                'ximaiimg' => [
                    'https://ssy.13yu.com/Public/shuiximai/bukeshuixi.png',
                    'http://ssy.13yu.com/Public/shuiximai/bukepiaobai.png',
                    'http://cdn.13yu.com/shuiximai/bukefanzhuanganzao.jpg',
                    'https://ssy.13yu.com/Public/shuiximai/diwenyuntang.png',
                    'https://ssy.13yu.com/Public/shuiximai/changuiganxi.png'
                ]
            ],[
                'ximaiid' => 13,
                'ximainame' => "防晒",
                'ximaiimg' => [
                    'https://ssy.13yu.com/Public/shuiximai/shouxi.png',
                    'https://ssy.13yu.com/Public/shuiximai/bukepiaobai.png',
                    'http://cdn.13yu.com/shuiximai/yinliangchulianggan.png',
                    'https://ssy.13yu.com/Public/shuiximai/bukeyuntang.png',
                    'https://ssy.13yu.com/Public/shuiximai/bukeganxi.png'
                ]
            ],[
                'ximaiid' => 11,
                'ximainame' => "其他",
                'ximaiimg' => [
                    'https://ssy.13yu.com/Public/shuiximai/qita.png'
                ]
            ]
        ];
        return result($data);
    }

    public function skuList(Request $request, LiningService $liningService)
    {
        $this->validate($request, [
            'type_no' => 'required'
        ]);
        $param = $request->all();
        $res = $liningService->getSku($param['type_no']);
        return result($res);
    }

    public function save(Request $request, LiningService $liningService)
    {
        $this->validate($request, [
            'data' => 'required'
        ]);
        $param = $request->all();
        $res = $liningService->save($param['data']);
        return $res['code'] === 0 ? success("保存成功") : error($res['msg'], $res);
    }

    public function printInfo(Request $request, LiningService $liningService)
    {
        $this->validate($request, [
            'type_no' => 'required'
        ]);
        $param = $request->all();
        $res = $liningService->printInfo($param['type_no']);
        return result($res);
    }

    public function status(Request $request, LiningService $liningService)
    {
        $this->validate($request, [
            'ids' => 'required',
            'status' => 'required'
        ]);
        $param = $request->all();
        $res = $liningService->checkStatus($param['ids'], $param['status']);
        return $res['code'] === 0 ? success("修改成功") : error($res['msg'], $res);
    }
}
